#pragma once

#include "ActiveObject.h"
#include "NullDeleter.h"

namespace RoomFW {

//
// Message handler to send messages after a delay.
//
class RetrySender : public ActiveObject::MessageHandler
{
public:
	//
	// Smart Pointer type.
	//
	typedef boost::shared_ptr<RetrySender> Ptr;
	typedef RoomFW::NullDeleter<RetrySender> NullDeleter;

	//
	// ctor.
	//
	RetrySender(ActiveObject* parent);

	//
	// Send a message after a delay.  First timeout in milliseconds.
	//
	void delaySend(int32_t timeout, const PortIndex& portIndex, MessageID messageID, IPayloadSP payload = IPayloadSP());
	void delaySend(const TimeValue& timeout, const PortIndex& portIndex, MessageID messageID, IPayloadSP payload = IPayloadSP());

	//
	// Handle messages override.
	//
	virtual bool handle(RoomMessageSP message);

private:

	//
	// Map timer id to message to send.
	//
	typedef std::map<RoomTimer::TimerId, RoomMessageSP> TimerMessageMap;
	TimerMessageMap map_;
};

} // End namespace
